<?php
class Form_Profile extends QForm
{
    function __construct($action)
    {
        // 调用父类的构造函数
        parent::__construct('form_profile', $action);

        // 从配置文件载入表单
        $filename = rtrim(dirname(__FILE__), '/\\') . DS . 'profile_form.yaml';
        $this->loadFromConfig(Helper_YAML::loadCached($filename));
        $this->addValidations(Admin::meta());
        $this['newpassword']->addValidations(array($this, 'checkpassword'), null, '两次输入的密码不同！');
      	$this['password']->addValidations(array($this, 'checkpwd'), null, '密码不能包含空格！');
      	$this['password']->addValidations('Helper_Util::cannot_null', null, '密码不能为空！');
    }
	
	function checkpassword($pwd) {
		$context = QContext::instance();
		return $context->newpassword ==  $context->password;
	}
	function checkpwd(){
		$password=QContext::instance()->password;
		return strpos($password, ' ') === false;
	}
}
